Skip to content

fix(memory): preserve native reranker score scale - #4249

Open
AaronZ345 wants to merge 2 commits into
volcengine:mainfrom
AaronZ345:aaron/fix-logit-reranker-recall
Open

fix(memory): preserve native reranker score scale#4249
AaronZ345 wants to merge 2 commits into
volcengine:mainfrom
AaronZ345:aaron/fix-logit-reranker-recall

Conversation

@AaronZ345

Copy link
Copy Markdown
Contributor

Summary

  • Stop clamping memory-plugin reranker scores and thresholds to [0, 1], so logit-scale rerankers can use native negative or >1 scores.
  • Apply the behavior consistently across shared recall logic and Claude/Codex/OpenCode/DSH/PI/ZCode integrations.
  • Update configuration docs and add regression tests for native-scale thresholds.

Root cause

The memory plugin path assumed reranker scores were cosine-like [0, 1] values. Local OpenAI-compatible rerankers such as bge-reranker-v2-m3 can return raw logits, where relevant results may be negative. Clamping both configured thresholds and item scores made valid operator settings like -8 ineffective and could filter out every recalled memory.

Fixes #4224.

Test plan

  • node --test examples/memory-plugin-shared/recall-core.test.mjs examples/memory-plugin-shared/agent-hook-runtime.test.mjs examples/opencode-plugin/tests/config.test.mjs examples/pi-coding-agent-extension/tests/config.test.mjs examples/dsh-memory-plugin/live-recall.test.mjs examples/codex-memory-plugin/scripts/config.test.mjs examples/claude-code-memory-plugin/scripts/config.test.mjs examples/codex-memory-plugin/scripts/auto-recall.test.mjs examples/claude-code-memory-plugin/scripts/auto-recall.test.mjs
  • git diff --check

Note: I also ran the broader memory-plugin PR test command after npm ci --prefix examples/dsh-memory-plugin. The #4224-related tests passed; unrelated local installer tests still fail in this checkout because the dev installer resolves the marketplace directory as /examples, and local TRAE CLI detection now includes trae-cn where existing assertions expect only trae.

Allow memory plugins to compare reranker scores in the provider's native scale so logit-based rerankers can use negative thresholds without losing all recall results.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Keep the rebased test helper's temporary CLI config paths so precedence checks exercise the intended fixtures.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
@AaronZ345
AaronZ345 force-pushed the aaron/fix-logit-reranker-recall branch from 9ac8905 to e3c5c4a Compare September 1, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Bug] Memory plugin recalls nothing with a logit-scale reranker: configured threshold is clamped to [0,1] and scores are clamped before comparison

1 participant